package com.jwdf.uda.ui.adapter.viewholder;

import android.databinding.DataBindingUtil;
import android.view.View;

import com.jwdf.uda.bean.PbBean;
import com.jwdf.uda.databinding.ItemGuideLikeBinding;
import com.jwdf.uda.ui.activity.UserInfoActivity;
import com.jwdf.uda.ui.adapter.AbsViewHolder;
import com.jwdf.uda.ui.adapter.item.GuideDetailItem;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 类说明：
 */
public class GuideLikeViewHolder extends AbsViewHolder<GuideDetailItem> {
    private ItemGuideLikeBinding mItemBinding;
    public GuideLikeViewHolder(View convertView) {
        super(convertView);
        mItemBinding = DataBindingUtil.bind(convertView);

        convertView.setOnClickListener(this);
    }

    @Override
    protected void onBindView(GuideDetailItem item) {
        PbBean.PbUserSimple like = item.like;
        if(like == null) return;
        ImageLoader.getInstance().displayImage(like.getAvatar().getUrl(), mItemBinding.ivHeader);
        mItemBinding.tvName.setText(like.getNickname());
//        mItemBinding.ivDesigner.setVisibility(View.GONE);
        mItemBinding.ivIsDesigner.setVisibility(like.getIsDesigner()?View.VISIBLE:View.GONE);
        mItemBinding.setIsDesigner(like.getIsDesigner());
    }

    @Override
    public void onClick(View v) {
        if(item.like != null){
            UserInfoActivity.start(v.getContext(), item.like.getUserId(), item.like.getIsDesigner());
        }
    }
}
